package com.ruoyi.goods.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.goods.mapper.StockBillMapper;
import com.ruoyi.goods.domain.StockBill;
import com.ruoyi.goods.service.IStockBillService;

/**
 * 出入库单据Service业务层处理
 *
 * @author lanmao
 * @date 2022-11-28
 */
@Service
public class StockBillServiceImpl extends ServiceImpl<StockBillMapper, StockBill> implements IStockBillService {

    @Autowired
    private ISysUserService sysUserService;

    /**
     * 查询出入库单据列表
     *
     * @param stockBill 出入库单据
     * @return 出入库单据
     */
    @Override
    public List<StockBill> selectStockBillList(StockBill stockBill) {
        List<StockBill> stockBills = getBaseMapper().selectStockBillList(stockBill);
        for (StockBill bill : stockBills) {
            SysUser user = sysUserService.selectUserById(bill.getOperatorId());
            bill.setOperatorName(user.getNickName());
        }
        return stockBills;
    }

    @Override
    public List<StockBill> getGoodsStock(Long goodsId) {
        return getBaseMapper().getGoodsStock(goodsId);
    }
}
